report  z_falv_012.

type-pools: slis.

data: gt_fieldcat type slis_t_fieldcat_alv,
      gs_fieldcat type slis_fieldcat_alv,
      gt_events   type slis_t_event,
      gs_event    type slis_alv_event.

data: gt_spfli type standard table of spfli.

start-of-selection.
  perform frm_get_data.
  perform frm_disp_data.

*&---------------------------------------------------------------------*
*&      Form  frm_get_data
*&---------------------------------------------------------------------*
form frm_get_data.
  select * from spfli into table gt_spfli.
endform.                    "frm_get_data


*&---------------------------------------------------------------------*
*&      Form  frm_disp_data
*&---------------------------------------------------------------------*
form frm_disp_data.
  call function 'Z_FALV_FIELD_CATALOG'
    exporting
      it_output     = gt_spfli[]
    tables
      field_catalog = gt_fieldcat[].

  " add events
  gs_event-name = 'PF_STATUS_SET'.
  gs_event-form = 'FRM_GUI_STATUS'.
  append gs_event to gt_events.
  clear gs_event.

  gs_event-name = 'USER_COMMAND'.
  gs_event-form = 'FRM_USER_COMMAND'.
  append gs_event to gt_events.

  gs_event-name = 'TOP_OF_PAGE'.
  gs_event-form = 'FRM_TOP_OF_PAGE'.
  append gs_event to gt_events.


  call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      i_callback_program = sy-repid
      it_events          = gt_events
      it_fieldcat        = gt_fieldcat[]
    tables
      t_outtab           = gt_spfli[].

endform.                    "frm_disp_data


*&---------------------------------------------------------------------*
*&      Form  frm_status_set
*&---------------------------------------------------------------------*
form frm_gui_status using ex_tab type slis_t_extab.
  set pf-status 'ZSTANDARD' excluding ex_tab immediately.
endform.                    "frm_status_set


*&---------------------------------------------------------------------*
*&      Form  user_command
*&---------------------------------------------------------------------*
form frm_user_command using p_ucomm    type sy-ucomm        " user command
                            p_selfield type slis_selfield.  " select field
  case p_ucomm.
    when 'EXCEL'.
      call function 'ZITAB_TO_EXCEL'
        exporting
          internal_tab = gt_spfli[].
  endcase.
endform.                    "user_command


*&---------------------------------------------------------------------*
*&      Form  FRM_TOP_OF_PAGE
*&---------------------------------------------------------------------*
form frm_top_of_page.
  data: ls_header type slis_listheader,
        lt_header type slis_t_listheader.

  ls_header-typ = 'H'.
  ls_header-info = '航班一览表'.
  append ls_header to lt_header.

  ls_header-typ = 'S'.
  concatenate '查询日期: ' sy-datum into ls_header-info.
  append ls_header to lt_header.


  call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
      it_list_commentary = lt_header
*     I_LOGO             =
*     I_END_OF_LIST_GRID =
      i_alv_form         = 'X'.

endform.                    "FRM_TOP_OF_PAGE